package com.zcx.qshop.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.zcx.helper.bound.BoundView;
import com.zcx.helper.bound.BoundViewHelper;
import com.zcx.qshop.QSApplication;
import com.zcx.qshop.R;
import com.zcx.qshop.conn.JsonAcountAsyGet;

import java.util.List;

/**
 * Created by Administrator on 2015/11/28.
 */
public class BalanceAdapter extends ArrayAdapter<JsonAcountAsyGet.Acount> {

    private LayoutInflater layoutInflater;

    public BalanceAdapter(Context context, List<JsonAcountAsyGet.Acount> objects) {

        super(context, 0, objects);

        layoutInflater = ((Activity)context).getLayoutInflater();

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        JsonAcountAsyGet.Acount acount = getItem(position);

        ViewHolder viewHolder;

        if(convertView == null){

            convertView = BoundViewHelper.boundView(viewHolder = new ViewHolder(), QSApplication.ScaleScreenHelper.loadView((ViewGroup) layoutInflater.inflate(R.layout.item_balance, null)));

            convertView.setTag(viewHolder);

        }else{

            viewHolder = (ViewHolder) convertView.getTag();

        }

        viewHolder.info.setText(acount.info);

        viewHolder.posttime.setText(acount.posttime);

        viewHolder.flowacount.setText(acount.flowacount);

        return convertView;

    }

    private class ViewHolder{

        @BoundView(R.id.item_balance_info) public TextView info;

        @BoundView(R.id.item_balance_posttime) public TextView posttime;

        @BoundView(R.id.item_balance_flowacount) public TextView flowacount;

    }

}
